package common;

import java.util.List;

import com.avaje.ebean.Ebean;
import com.avaje.ebean.SqlRow;

import models.edu_courses;

public class MobileUtils {
	
	public static boolean IsAuthenticatedDevice(String userDeviceId){
		Object[] eu=edu_courses.findByUserDeviceId(userDeviceId);
        if(eu.length >0){
        	return true;
        }
        return false;
	}
	
	public static Object[] findUserDevice(String userDeviceId){
		Object[] eu=edu_courses.findByUserDeviceId(userDeviceId);
		return eu;
	}
	
	public static int findUserIdFromDeviceId(String userDeviceId){
		String s="SELECT edu_users.user_id FROM edu_courses Where edu_users.user_device_id='"+userDeviceId+"'";
		List<SqlRow> rows = Ebean.createSqlQuery(s).findList();
		return rows.get(0).getInteger("user_id");
	}
}
